﻿using MexicanControl.model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using static MexicanControl.model.Save;

namespace MexicanControl
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void exit_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2)
                {
                    MessageBoxResult result = MessageBox.Show("Exit orders will not be made,Do you really want to quit?", "Exit", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses())
                        {
                            if (thisProc.ProcessName == "SouthKoreaCoffee")
                            {
                                if (!thisProc.CloseMainWindow())
                                    thisProc.Kill(); //当发送关闭窗口命令无效时强行结束进程     
                            }
                            if (thisProc.ProcessName == "MINIGKP")
                            {
                                if (!thisProc.CloseMainWindow())
                                    thisProc.Kill(); //当发送关闭窗口命令无效时强行结束进程     
                            }
                        }
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            System.Windows.Application.Current.Shutdown();
                        }));
                    }
                }
            }
            catch (Exception)
            {
                return;
            }

        }
        /// <summary>
        ///   状态  0 关状态  1 开状态 2 已开机 3 上电 4 下电 5 已使能 6 下使能 7 已运行 8 继续运行 9 已报警 10 已暂停  11已停止 ,12 机械臂状态查询
        /// </summary>
        /// <param name="robotName"></param>
        /// <param name="type"> </param>
        public void Robot_CZ(string robotName, int type)
        {
            try
            {
                if (isRobot)
                {
                    if (CoffeeSocket != null)
                    {

                        ClientList clientList = new ClientList();
                        MessageClientList coffeelist = MessageClientList.Instance;
                        coffeelist.Name = robotName;
                        coffeelist.type = type;
                        clientList.message = coffeelist;
                        clientList.code = 3;
                        CoffeeSocket.Send(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(clientList)));
                    }
                }
                else
                {
                    MessageBox.Show("Please update later, the program is loading!");
                }
            }
            catch (Exception)
            {
                return;
            }
        }
        private void L_SD_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_SD.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 2);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_BJ_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_BJ.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 9);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_BTSD_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_BTSD.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 3);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_BTXD_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_BTXD.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 4);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_SSN_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_SSN.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 5);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_XSN_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_XSN.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 6);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_YXCX_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_YXCX.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 7);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_TZCX_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_TZCX.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 11);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_ZTCX_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_ZTCX.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 10);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void L_JXCX_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (L_JXCX.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_L", 8);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_SD_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_SD.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 2);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_BJ_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_BJ.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 9);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_BTSD_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_BTSD.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 3);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_BTXD_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_BTXD.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 4);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_SSN_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_SSN.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 5);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_XSN_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_XSN.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 6);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_YXCX_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_YXCX.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 7);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_TZCX_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_TZCX.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 11);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_ZTCX_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_ZTCX.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 10);
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void R_JXCX_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (R_JXCX.Tag.ToString() == "1")
                {
                    Robot_CZ("Reload_R", 8);
                }
            }
            catch (Exception)
            {
                return;
            }
        }


        private void Reload_R_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Robot_CZ("Reload_R", 12);
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Reload_L_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Robot_CZ("Reload_L", 12);
            }
            catch (Exception)
            {
                return;
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                wuliao.Visibility = Visibility.Visible;
                caozuo.Visibility = Visibility.Collapsed;
                CoffeeQuYu.Visibility = Visibility.Collapsed;
            }
            catch (Exception)
            {
                return;
            }
        }

        private void CoffeeRobot_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                wuliao.Visibility = Visibility.Collapsed;
                caozuo.Visibility = Visibility.Collapsed;
                CoffeeQuYu.Visibility = Visibility.Visible;
            }
            catch (Exception)
            {
                return;
            }
        }

        private void NaichaRobot_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                wuliao.Visibility = Visibility.Collapsed;
                caozuo.Visibility = Visibility.Collapsed;
                CoffeeQuYu.Visibility = Visibility.Collapsed;
            }
            catch (Exception)
            {
                return;
            }
        }

        private void DDZZ_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                wuliao.Visibility = Visibility.Collapsed;
                caozuo.Visibility = Visibility.Visible;
                CoffeeQuYu.Visibility = Visibility.Collapsed;
            }
            catch (Exception)
            {
                return;
            }
        }
        public void Send(string name, string tag)
        {
            try
            {
                if (CoffeeSocket != null)
                {

                    ClientList clientList = new ClientList();
                    MessageClientList coffeelist = MessageClientList.Instance;
                    coffeelist.Name = name;
                    coffeelist.type = double.TryParse(tag, out double do1) ? do1 : 0;
                    clientList.message = coffeelist;
                    clientList.code = 0;
                    CoffeeSocket.Send(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(clientList)));

                }
            }
            catch (Exception)
            {
                return;
            }
        }
        public void Sends(string name, string tag)
        {
            try
            {
                if (isRobot)
                {
                    if (CoffeeSocket != null)
                    {

                        ClientList clientList = new ClientList();
                        MessageClientList coffeelist = MessageClientList.Instance;
                        coffeelist.Name = name;
                        coffeelist.type = int.TryParse(tag, out int do1) ? do1 : 0;
                        clientList.message = coffeelist;
                        clientList.code = 0;
                        CoffeeSocket.Send(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(clientList)));

                    }
                }
                else
                {
                    MessageBox.Show("Please update later, the program is loading!");
                }
            }
            catch (Exception)
            {
                return;
            }
        }
        public static Socket serverSocket;
        public static Socket CoffeeSocket;
        public static Socket IceSocket;
        public static Socket DPSocket;
        private static byte[] result = new byte[20480];
        private static int myProt = 8885;  //端口 
        public static bool ismake = false;
        public static bool isRobot = false;
        public List<ClientList> clientLists = new List<ClientList>();
        public static string IPorPortUrl = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"\IPorPortMessage.txt";
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!File.Exists(IPorPortUrl))
                {
                    using (FileStream stream = File.Create(IPorPortUrl))
                    {
                        stream.Close();
                        stream.Dispose();
                        IPorPortInfo porPortInfo1 = IPorPortInfo.Instance;
                        File.WriteAllText(IPorPortUrl, JsonConvert.SerializeObject(porPortInfo1));
                    }
                }
                else
                {
                    var dd = File.ReadAllText(IPorPortUrl);
                    var porPortInfo = JsonConvert.DeserializeObject<IPorPortInfo>(File.ReadAllText(IPorPortUrl));
                    IPorPortInfo.Instance.CoffeeIP = porPortInfo.CoffeeIP;
                    IPorPortInfo.Instance.CoffeePort = porPortInfo.CoffeePort;
                    IPorPortInfo.Instance.RobotIPLeft = porPortInfo.RobotIPLeft;
                    IPorPortInfo.Instance.RobotIPRight = porPortInfo.RobotIPRight;
                    IPorPortInfo.Instance.PortName = porPortInfo.PortName;
                    IPorPortInfo.Instance.PrinterCoffeeIP = porPortInfo.PrinterCoffeeIP;
                    IPorPortInfo.Instance.PrinterCofferPort = porPortInfo.PrinterCofferPort;
                    IPorPortInfo.Instance.EWMPortName = porPortInfo.EWMPortName;
                    IPorPortInfo.Instance.ZBPortName = porPortInfo.ZBPortName;
                    IPorPortInfo.Instance.ZBPortName2 = porPortInfo.ZBPortName2;
                    IPorPortInfo.Instance.CoffeePortName = porPortInfo.CoffeePortName;
                    IPorPortInfo.Instance.url_start = porPortInfo.url_start;
                    IPorPortInfo.Instance.deviceID = porPortInfo.deviceID;
                    IPorPortInfo.Instance.SugarInit1 = porPortInfo.SugarInit1;
                    IPorPortInfo.Instance.SugarInit2 = porPortInfo.SugarInit2;
                    IPorPortInfo.Instance.SugarInit3 = porPortInfo.SugarInit3;
                    IPorPortInfo.Instance.SugarInit4 = porPortInfo.SugarInit4;
                    IPorPortInfo.Instance.SugarInit5 = porPortInfo.SugarInit5;
                    IPorPortInfo.Instance.SugarInit6 = porPortInfo.SugarInit6;
                    WuLiaoCoffeeSel.Instance.SugarInit1 = porPortInfo.SugarInit1;
                    WuLiaoCoffeeSel.Instance.SugarInit2 = porPortInfo.SugarInit2;
                    WuLiaoCoffeeSel.Instance.SugarInit3 = porPortInfo.SugarInit3;
                    WuLiaoCoffeeSel.Instance.SugarInit4 = porPortInfo.SugarInit4;
                    WuLiaoCoffeeSel.Instance.SugarInit5 = porPortInfo.SugarInit5;
                    WuLiaoCoffeeSel.Instance.SugarInit6 = porPortInfo.SugarInit6;
                }
                this.Dispatcher.BeginInvoke(new Action(delegate
                {
                    var ips = IPorPortInfo.Instance.CoffeeIP.Split('.');
                    deviceID.Text = IPorPortInfo.Instance.deviceID.ToString();
                    IP.Text = ips.Count() == 4 ? ips[2] : "";
                }));
                saveDeviceMatter save = new saveDeviceMatter();
                save.matterStatusJson = JsonConvert.SerializeObject(CoffeeMatters.Instance);
                save.deviceStatusJson = JsonConvert.SerializeObject(deviceStatus.Instance);
                var saves = JsonConvert.SerializeObject(save);
                HttpMsg.Instance.saveDeviceMatterMsg(saves);
                CoffeeMake();
            }
            catch (Exception)
            {
                return;
            }
        }
        #region 服务器链接
        /// <summary>
        /// 服务器启动监听各种信息动态
        /// </summary>
        public void CoffeeMake()
        {
            try
            {
                string LocalIP = "192.168.0.77";
                var host = Dns.GetHostEntry(Dns.GetHostName());
                foreach (var ips in host.AddressList)
                {
                    if (ips.AddressFamily == AddressFamily.InterNetwork)
                    {
                        LocalIP = ips.ToString();
                        // Console.WriteLine"IP Address = " + (ips.ToString());
                    }
                }
                //服务器IP地址 
                IPAddress ip = IPAddress.Parse(LocalIP);
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                serverSocket.Bind(new IPEndPoint(ip, myProt)); //绑定IP地址：端口 
                serverSocket.Listen(10);  //设定最多10个排队连接请求 
                Console.WriteLine("启动监听{0}成功", serverSocket.LocalEndPoint.ToString());
                //通过Clientsoket发送数据 
                Thread myThread = new Thread(ListenClientConnect);
                myThread.IsBackground = true;
                myThread.Start();
                Thread thread1 = new Thread(MsgShowServer);
                thread1.IsBackground = true;
                thread1.Start();
                foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses())
                {
                    if (thisProc.ProcessName == "SouthKoreaCoffee")
                    {
                        if (!thisProc.CloseMainWindow())
                            thisProc.Kill(); //当发送关闭窗口命令无效时强行结束进程     
                    }
                    if (thisProc.ProcessName == "MINIGKP")
                    {
                        if (!thisProc.CloseMainWindow())
                            thisProc.Kill(); //当发送关闭窗口命令无效时强行结束进程     
                    }
                }
                Process ps = new Process();
                string yourURL = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"coffee";
                ps.StartInfo.FileName = "SouthKoreaCoffee.exe";
                ps.StartInfo.WorkingDirectory = yourURL;
                ps.Start();
                Thread.Sleep(1000);
                Process ps1 = new Process();
                string yourURL1 = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"显示屏";
                ps1.StartInfo.FileName = "MINIGKP.exe";
                ps1.StartInfo.WorkingDirectory = yourURL1;
                ps1.Start();
            }
            catch (Exception ex)
            {
                serverSocket.Shutdown(SocketShutdown.Both);
                serverSocket.Close();
                CoffeeMake();
                return;
            }
        }
        /// <summary> 
        /// 监听客户端连接 
        /// </summary> 
        private void ListenClientConnect()
        {
            try
            {
                while (true)
                {
                    Socket clientSocket = serverSocket.Accept();
                    string ip = ((IPEndPoint)clientSocket.RemoteEndPoint).Address.ToString();
                    Console.WriteLine("点单");
                    Thread receiveThread = new Thread(ReceiveMessage);
                    receiveThread.IsBackground = true;
                    receiveThread.Start(clientSocket);
                    Thread.Sleep(10);
                }
            }
            catch (Exception)
            {
                return;
            }
        }
        public void MsgShowServer()
        {

            try
            {
                while (true)
                {
                    try
                    {
                        if (clientLists.Count > 0)
                        {
                            var making = clientLists[0];
                            if (making != null)
                            {
                                if (making.code == 1)
                                {
                                    //  IceMsg(making.MsgIceBol);
                                }
                                else if (making.code == 2)
                                {
                                    CoffeeMsg(making.MsgBol);
                                }
                                else if (making.code == 3)
                                {
                                    if (making.message.Name == "Reload_L")
                                    {
                                        RobotSel_L(making.robotMsg);
                                    }
                                }
                                else if (making.code == 0)
                                {
                                    DOSelect(making.message.Name, making.message.type);
                                }
                                else if (making.code == 13)
                                {
                                    isRobot = true;
                                }
                                else if (making.code == 10)
                                {
                                    if (DPSocket != null)
                                    {
                                        Thread.Sleep(1000);
                                        ClientList clientList = new ClientList();
                                        MessageClientList coffeelist = MessageClientList.Instance;
                                        ClientDP.Instance.IsMakeInit1 = making.DP.IsMakeInit1;
                                        ClientDP.Instance.IsMakeInit2 = making.DP.IsMakeInit2;
                                        ClientDP.Instance.orderNum1 = making.DP.orderNum1;
                                        ClientDP.Instance.orderNum2 = making.DP.orderNum2;
                                        ClientDP.Instance.OrderId1 = making.DP.OrderId1;
                                        ClientDP.Instance.OrderId2 = making.DP.OrderId2;
                                        clientList.code = 10;
                                        clientList.DP = ClientDP.Instance;
                                        DPSocket.Send(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(clientList)));
                                        ismake = making.IsMake;
                                    }
                                }
                                else if (making.code == 12)
                                {
                                    Thread.Sleep(1000);
                                    ClientList clientList = new ClientList();
                                    clientList.code = 12;
                                    ClientDP.Instance.IsMakeInit1 = making.DP.IsMakeInit1;
                                    ClientDP.Instance.IsMakeInit2 = making.DP.IsMakeInit2;
                                    ClientDP.Instance.orderNum1 = making.DP.orderNum1;
                                    ClientDP.Instance.orderNum2 = making.DP.orderNum2;
                                    ClientDP.Instance.OrderId1 = making.DP.OrderId1;
                                    ClientDP.Instance.OrderId2 = making.DP.OrderId2;
                                    clientList.DP = ClientDP.Instance;
                                    DPSocket.Send(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(clientList)));
                                    ismake = making.IsMake;
                                }
                            }
                            clientLists.RemoveAt(0);
                        }
                    }
                    catch (Exception)
                    {
                    }
                    Thread.Sleep(100);
                }
            }
            catch (Exception)
            {
                return;
            }
        }
        /// <summary> 
        /// 接收消息 
        /// </summary> 
        /// <param name="clientSocket"></param> 
        private void ReceiveMessage(object clientSockets)
        {
            Socket myClientSocket = (Socket)clientSockets;

            while (true)
            {
                try
                {
                    //通过clientSocket接收数据 
                    int receiveNumber = myClientSocket.Receive(result);
                    if (receiveNumber == 0) continue;
                    try
                    {
                        var msg = Encoding.UTF8.GetString(result, 0, receiveNumber);
                        if (msg.Trim().Length != 0)
                        {
                            var making = JsonConvert.DeserializeObject<ClientList>(msg);
                            if (making != null)
                            {
                                if (making.code == 4)
                                {
                                    CoffeeSocket = myClientSocket;
                                }
                                else if (making.code == 5)
                                {
                                    IceSocket = myClientSocket;
                                }
                                else if (making.code == 11)
                                {
                                    DPSocket = myClientSocket;
                                    //if (DPSocket != null)
                                    //{
                                    //    Thread.Sleep(1000);
                                    //    ClientList clientList = new ClientList();
                                    //    MessageClientList coffeelist = MessageClientList.Instance;
                                    //    clientList.message = coffeelist;
                                    //    clientList.IsMake = ismake;
                                    //    DPSocket.Send(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(clientList)));
                                    //}
                                }
                                else
                                    clientLists.Add(making);
                            }
                        }
                        Thread.Sleep(10);
                    }
                    catch (Exception)
                    {
                    }
                }
                catch (Exception ex)
                {
                    break;
                }
            }

        }
        public void CoffeeMsg(WuLiaoCoffeeSel wuLiaoCoffee)
        {
            try
            {

                CoffeeMatters.Instance.CoffeeMatter1 = wuLiaoCoffee.Water_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter2 = wuLiaoCoffee.Water2_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter14 = wuLiaoCoffee.Levulose1_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter12 = wuLiaoCoffee.Levulose2_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter11 = wuLiaoCoffee.Levulose3_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter21 = wuLiaoCoffee.Levulose4_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter22 = wuLiaoCoffee.Levulose5_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter23 = wuLiaoCoffee.Levulose6_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter19 = wuLiaoCoffee.Milk_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter8 = wuLiaoCoffee.CupFeed1_Sel_Bol || wuLiaoCoffee.CupFeed2_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter10 = wuLiaoCoffee.LidFeed1_Sel_Bol ? 1 : 0;
                //CoffeeMatters.Instance.CoffeeMatter12 = wuLiaoCoffee.Lid2_Sel_Bol ? 1 : 0;
                //CoffeeMatters.Instance.CoffeeMatter13 = wuLiaoCoffee.Lid3_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter17 = wuLiaoCoffee.CoffeeBean_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter4 = wuLiaoCoffee.RobotWarn ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter6 = wuLiaoCoffee.Ice1_Sel_Bol ? 1 : 0;
                CoffeeMatters.Instance.CoffeeMatter3 = wuLiaoCoffee.CoffeeWarn ? 1 : 0;
                this.Dispatcher.BeginInvoke(new Action(delegate
                {
                    WATER1_B.Background = wuLiaoCoffee.Water_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    WATER1_F.Foreground = wuLiaoCoffee.Water_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    WATER2_B.Background = wuLiaoCoffee.Water2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    WATER2_F.Foreground = wuLiaoCoffee.Water2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //WATER3_B.Background = wuLiaoCoffee.Water3_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //WATER3_F.Foreground = wuLiaoCoffee.Water3_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //WATER4_B.Background = wuLiaoCoffee.Water4_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //WATER4_F.Foreground = wuLiaoCoffee.Water4_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //WATER5_B.Background = wuLiaoCoffee.Water5_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //WATER5_F.Foreground = wuLiaoCoffee.Water5_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //SYBJ1_B.Background = wuLiaoCoffee.WaterYBJ1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //SYBJ1_F.Foreground = wuLiaoCoffee.WaterYBJ1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //SYBJ2_B.Background = wuLiaoCoffee.WaterYBJ2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //SYBJ2_F.Foreground = wuLiaoCoffee.WaterYBJ2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //SYBJ3_B.Background = wuLiaoCoffee.WaterYBJ3_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //SYBJ3_F.Foreground = wuLiaoCoffee.WaterYBJ3_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //SYBJ4_B.Background = wuLiaoCoffee.WaterYBJ4_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //SYBJ4_F.Foreground = wuLiaoCoffee.WaterYBJ4_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //SYBJ5_B.Background = wuLiaoCoffee.WaterYBJ5_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //SYBJ5_F.Foreground = wuLiaoCoffee.WaterYBJ5_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    GT1_B.Background = wuLiaoCoffee.Levulose1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    GT1_F.Foreground = wuLiaoCoffee.Levulose1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    GT2_B.Background = wuLiaoCoffee.Levulose2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    GT2_F.Foreground = wuLiaoCoffee.Levulose2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    GT3_B.Background = wuLiaoCoffee.Levulose3_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    GT3_F.Foreground = wuLiaoCoffee.Levulose3_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    GT4_B.Background = wuLiaoCoffee.Levulose4_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    GT4_F.Foreground = wuLiaoCoffee.Levulose4_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    GT5_B.Background = wuLiaoCoffee.Levulose5_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    GT5_F.Foreground = wuLiaoCoffee.Levulose5_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    GT6_B.Background = wuLiaoCoffee.Levulose6_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    GT6_F.Foreground = wuLiaoCoffee.Levulose6_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    MILK_B.Background = wuLiaoCoffee.Milk_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    MILK_F.Foreground = wuLiaoCoffee.Milk_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //NNYBJ_B.Background = wuLiaoCoffee.Milk2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //NNYBJ_F.Foreground = wuLiaoCoffee.Milk2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    CUP_B.Background = wuLiaoCoffee.CupFeed1_Sel_Bol || wuLiaoCoffee.CupFeed2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    CUP_F.Foreground = wuLiaoCoffee.CupFeed1_Sel_Bol || wuLiaoCoffee.CupFeed2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    GJC1_B.Background = wuLiaoCoffee.LidFeed1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    GJC1_F.Foreground = wuLiaoCoffee.LidFeed1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //GJC2_B.Background = wuLiaoCoffee.Lid2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //GJC2_F.Foreground = wuLiaoCoffee.Lid2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    //GJC3_B.Background = wuLiaoCoffee.Lid3_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    //GJC3_F.Foreground = wuLiaoCoffee.Lid3_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    CCJC1_B.Background = wuLiaoCoffee.OutMealCup_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    CCJC1_F.Foreground = wuLiaoCoffee.OutMealCup_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    CCJC2_B.Background = wuLiaoCoffee.OutMealCup2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    CCJC2_F.Foreground = wuLiaoCoffee.OutMealCup2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    JBCGJC1_B.Background = wuLiaoCoffee.TakeCup_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    JBCGJC1_F.Foreground = wuLiaoCoffee.TakeCup_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    DJC1_B.Background = wuLiaoCoffee.CoffeeBean_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    DJC1_F.Foreground = wuLiaoCoffee.CoffeeBean_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    TGSDW1_B.Background = wuLiaoCoffee.PushRodUP1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    TGSDW1_F.Foreground = wuLiaoCoffee.PushRodUP1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    TGXDW1_B.Background = wuLiaoCoffee.PushRodDown1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    TGXDW1_F.Foreground = wuLiaoCoffee.PushRodDown1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    TGSDW2_B.Background = wuLiaoCoffee.PushRodUP2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    TGSDW2_F.Foreground = wuLiaoCoffee.PushRodUP2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    TGXDW2_B.Background = wuLiaoCoffee.PushRodDown2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    TGXDW2_F.Foreground = wuLiaoCoffee.PushRodDown2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    YGTGSDW_B.Background = wuLiaoCoffee.YGSDW_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    YGTGSDW_F.Foreground = wuLiaoCoffee.YGSDW_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    YGTGXDW_B.Background = wuLiaoCoffee.YGXDW_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    YGTGXDW_F.Foreground = wuLiaoCoffee.YGXDW_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    YGTGZDW_B.Background = wuLiaoCoffee.YGZDW_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    YGTGZDW_F.Foreground = wuLiaoCoffee.YGZDW_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    CZ1_B.Background = wuLiaoCoffee.Weigh1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    CZ1_F.Foreground = wuLiaoCoffee.Weigh1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    LBFK1_B.Background = wuLiaoCoffee.LBQFK1_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    LBFK1_F.Foreground = wuLiaoCoffee.LBQFK1_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    LBFK2_B.Background = wuLiaoCoffee.LBQFK2_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    LBFK2_F.Foreground = wuLiaoCoffee.LBQFK2_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    LGFK1_B.Background = wuLiaoCoffee.LGQFK1_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    LGFK1_F.Foreground = wuLiaoCoffee.LGQFK1_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    AQGS1_B.Background = wuLiaoCoffee.BANNER1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    AQGS1_F.Foreground = wuLiaoCoffee.BANNER1_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    AQGS2_B.Background = wuLiaoCoffee.BANNER2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(19, 220, 40)) : new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    AQGS2_F.Foreground = wuLiaoCoffee.BANNER2_Sel_Bol ? new SolidColorBrush(Color.FromRgb(255, 0, 0)) : new SolidColorBrush(Color.FromRgb(17, 179, 183));
                    TTime1.Text = wuLiaoCoffee.SugarInit1.ToString();
                    TTime2.Text = wuLiaoCoffee.SugarInit2.ToString();
                    TTime3.Text = wuLiaoCoffee.SugarInit3.ToString();
                    TTime4.Text = wuLiaoCoffee.SugarInit4.ToString();
                    TTime5.Text = wuLiaoCoffee.SugarInit5.ToString();
                    TTime6.Text = wuLiaoCoffee.SugarInit6.ToString();
                }));
                TestDelegateInvoke testDelegate = new TestDelegateInvoke(DelegateInvokeMethod);
                testDelegate.BeginInvoke(null, null);
            }
            catch (Exception)
            {
                return;
            }
        }

        public delegate void TestDelegateInvoke();

        private void DelegateInvokeMethod()
        {
            try
            {
                saveDeviceMatter save = new saveDeviceMatter();
                save.matterStatusJson = JsonConvert.SerializeObject(CoffeeMatters.Instance);
                save.deviceStatusJson = JsonConvert.SerializeObject(deviceStatus.Instance);
                var saves = JsonConvert.SerializeObject(save);
                HttpMsg.Instance.saveDeviceMatterMsg(saves);

            }
            catch (Exception)
            {
                return;
            }
        }
        /// <summary>
        /// 单个按钮改变状态
        /// </summary>
        /// <param name="name"></param>
        /// <param name="tag"></param>
        public void DOSelect(string name, double tag)
        {
            try
            {
                switch (name)
                {
                    case "JG1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            JG1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            JG1_IMG.Tag = tag;
                            JG1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));

                        }));
                        break;
                    case "YG1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YG1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YG1_IMG.Tag = tag;
                            YG1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "LGDJXJ1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            LGDJXJ1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            LGDJXJ1_IMG.Tag = tag;
                            LGDJXJ1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "YGDJQJ1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YGDJQJ1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YGDJQJ1_IMG.Tag = tag;
                            YGDJQJ1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "YGDJHT1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YGDJHT1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YGDJHT1_IMG.Tag = tag;
                            YGDJHT1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "JG2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            JG2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            JG2_IMG.Tag = tag;
                            JG2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));

                        }));
                        break;
                    case "YG2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YG2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YG2_IMG.Tag = tag;
                            YG2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "LGDJXJ2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            LGDJXJ2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            LGDJXJ2_IMG.Tag = tag;
                            LGDJXJ2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "YGDJQJ2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YGDJQJ2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YGDJQJ2_IMG.Tag = tag;
                            YGDJQJ2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "YGDJHT2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YGDJHT2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YGDJHT2_IMG.Tag = tag;
                            YGDJHT2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "JG3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            JG3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            JG3_IMG.Tag = tag;
                            JG3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));

                        }));
                        break;
                    case "YG3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YG3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YG3_IMG.Tag = tag;
                            YG3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "LGDJXJ3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            LGDJXJ3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            LGDJXJ3_IMG.Tag = tag;
                            LGDJXJ3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "YGDJQJ3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YGDJQJ3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YGDJQJ3_IMG.Tag = tag;
                            YGDJQJ3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "CB":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            CB_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            CB_IMG.Tag = tag;
                            CB_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "YGDJHT3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            YGDJHT3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            YGDJHT3_IMG.Tag = tag;
                            YGDJHT3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "TGS1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            TGS1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            TGS1_IMG.Tag = tag;
                            TGS1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "TGX1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            TGX1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            TGX1_IMG.Tag = tag;
                            TGX1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "TGS2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            TGS2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            TGS2_IMG.Tag = tag;
                            TGS2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "TGX2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            TGX2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            TGX2_IMG.Tag = tag;
                            TGX2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "TGS3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            TGS3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            TGS3_IMG.Tag = tag;
                            TGS3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "TGX3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            TGX3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            TGX3_IMG.Tag = tag;
                            TGX3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "TGZ":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            TGZ_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            TGZ_IMG.Tag = tag;
                            TGZ_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "LB":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            LB_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            LB_IMG.Tag = tag;
                            LB_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "LB2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            LB2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            LB2_IMG.Tag = tag;
                            LB2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "LG1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            LG1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            LG1_IMG.Tag = tag;
                            LG1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "LG2":
                        //this.Dispatcher.BeginInvoke(new Action(delegate
                        //{
                        //    LG2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                        //    LG2_IMG.Tag = tag;
                        //    LG2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        //}));
                        break;
                    case "LG3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            LG3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            LG3_IMG.Tag = tag;
                            LG3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "GT1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            GT1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            GT1_IMG.Tag = tag;
                            GT1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "GT2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            GT2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            GT2_IMG.Tag = tag;
                            GT2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "GT3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            GT3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            GT3_IMG.Tag = tag;
                            GT3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "GT4":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            GT4_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            GT4_IMG.Tag = tag;
                            GT4_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "GT5":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            GT5_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            GT5_IMG.Tag = tag;
                            GT5_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "GT6":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            GT6_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            GT6_IMG.Tag = tag;
                            GT6_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "SF1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            SF1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            SF1_IMG.Tag = tag;
                            SF1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "SF2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            SF2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            SF2_IMG.Tag = tag;
                            SF2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "SF3":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            SF3_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            SF3_IMG.Tag = tag;
                            SF3_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "SF4":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            SF4_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            SF4_IMG.Tag = tag;
                            SF4_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "SF5":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            SF5_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            SF5_IMG.Tag = tag;
                            SF5_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "QBQJ":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            QBQJ_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            QBQJ_IMG.Tag = tag;
                            QBQJ_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "QBHT":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            QBHT_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            QBHT_IMG.Tag = tag;
                            QBHT_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "FYJ1":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            FYJ1_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            FYJ1_IMG.Tag = tag;
                            FYJ1_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    case "FYJ2":
                        this.Dispatcher.BeginInvoke(new Action(delegate
                        {
                            FYJ2_KG.Text = tag == 1 ? "开(ON)" : "关(OFF)";
                            FYJ2_IMG.Tag = tag;
                            FYJ2_IMG.Source = tag == 1 ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关开.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"开关关.png"));
                        }));
                        break;
                    default:
                        break;
                }
            }
            catch (Exception)
            {
                return;
            }
        }
        /// <summary>
        /// 给按钮变颜色
        /// </summary>
        /// <param name="btn">要变颜色得按钮</param>
        /// <param name="type">1，正常 2，接通变1 3，不缺料 4，缺料</param>
        /// <param name="img">要变颜色得按钮 开</param>
        ///  <param name="img1">要变颜色得按钮 关</param>
        public void BtnShow(Button btn, int type, Image img, Image img1)
        {
            try
            {
                this.Dispatcher.BeginInvoke(new Action(delegate
                {
                    if (type == 0)//正常状态do
                    {
                        btn.Tag = 0;
                        img.Source = new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png"));
                        img1.Source = new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png"));

                    }
                    else if (type == 1)//接通变1do
                    {
                        btn.Tag = 1;
                        img1.Source = new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png"));
                        img.Source = new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png"));
                    }
                }));
            }
            catch (Exception)
            {
                return;
            }
        }

        public void RobotSel_L(RobotMsg robotMsg)
        {
            try
            {
                this.Dispatcher.BeginInvoke(new Action(delegate
                {
                    robot_kj_L.Source = robotMsg.Robot_YKJ_L ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png"));
                    robot_sd_L.Source = robotMsg.Robot_SD_L ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png"));
                    robot_sn_L.Source = robotMsg.Robot_SN_L ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png"));
                    robot_yx_L.Source = robotMsg.Robot_YX_L ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png"));
                    robot_zt_L.Source = robotMsg.Robot_ZT_L ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png"));
                    robot_bj_L.Source = robotMsg.Robot_BJ_L ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png"));
                    robot_tz_L.Source = robotMsg.Robot_TZ_L ? new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"绿圆.png")) : new BitmapImage(new Uri(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"灰圆.png")); ;
                    RobotYN_L(robotMsg);
                }));
            }
            catch (Exception)
            {
                return;
            }
        }
        public void RobotYN_L(RobotMsg robotMsg)
        {
            try
            {
                LTypeKJ_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LTypeBJ_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LOpenBTDY_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LCloseBTDY_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LOpenSSN_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LCloseSSN_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LOpenYXCX_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LCloseTZCX_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LContinueZTCX_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                LCloseJXCX_L.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                L_SD.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_BJ.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_BTSD.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_BTXD.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_SSN.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_XSN.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_YXCX.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_ZTCX.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_TZCX.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_JXCX.Foreground = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                L_SD.Tag = "0";
                L_BJ.Tag = "0";
                L_BTSD.Tag = "0";
                L_BTXD.Tag = "0";
                L_SSN.Tag = "0";
                L_XSN.Tag = "0";
                L_YXCX.Tag = "0";
                L_ZTCX.Tag = "0";
                L_TZCX.Tag = "0";
                L_JXCX.Tag = "0";
                if (!robotMsg.Robot_YKJ_L && !robotMsg.Robot_BJ_L && !robotMsg.Robot_YX_L && !robotMsg.Robot_SN_L && !robotMsg.Robot_ZT_L && !robotMsg.Robot_SD_L && !robotMsg.Robot_TZ_L)
                {
                    LTypeKJ_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    L_SD.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_SD.Tag = "1";
                }
                else if (robotMsg.Robot_YKJ_L)
                {
                    LOpenBTDY_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    L_BTSD.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_BTSD.Tag = "1";
                }
                else if (robotMsg.Robot_SD_L)
                {
                    LCloseBTDY_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    LOpenSSN_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    L_BTXD.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_SSN.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_BTXD.Tag = "1";
                    L_SSN.Tag = "1";
                }
                else if (robotMsg.Robot_SN_L)
                {
                    LOpenYXCX_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    LCloseSSN_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    L_YXCX.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_XSN.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_XSN.Tag = "1";
                    L_YXCX.Tag = "1";
                }
                else if (robotMsg.Robot_YX_L)
                {
                    LCloseTZCX_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    LContinueZTCX_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    L_TZCX.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_ZTCX.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_ZTCX.Tag = "1";
                    L_TZCX.Tag = "1";
                }
                else if (robotMsg.Robot_TZ_L)
                {
                    LOpenYXCX_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    LCloseSSN_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    L_YXCX.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_XSN.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_XSN.Tag = "1";
                    L_YXCX.Tag = "1";
                }
                else if (robotMsg.Robot_ZT_L)
                {
                    LCloseTZCX_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    LCloseJXCX_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    L_JXCX.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_TZCX.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_JXCX.Tag = "1";
                    L_TZCX.Tag = "1";
                }
                else if (robotMsg.Robot_BJ_L)
                {
                    LTypeBJ_L.Background = new SolidColorBrush(Color.FromRgb(125, 142, 67));
                    L_BJ.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));
                    L_BJ.Tag = "1";
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        #endregion
        private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            try
            {
                // 检查输入的字符是否为数字
                if (!Regex.IsMatch(e.Text, "^[0-9]+$"))
                {
                    e.Handled = true;
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GSCLTime_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Send("GSCLTime", GSCLTime.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Caozuo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                wuliao.Visibility = Visibility.Collapsed;
                caozuo.Visibility = Visibility.Visible;
                CoffeeQuYu.Visibility = Visibility.Collapsed;
            }
            catch (Exception)
            {
                return;
            }
        }

        private void LB_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("LB", LB_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void LG1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("LG1", LG1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void LG2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
              //  Send("LG2", LG2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void LG3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("LG3", LG3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void JG1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("JG1", JG1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YG1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YG1", YG1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void LB8_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {

        }

        private void TTime1_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {

                Send("GTS1", (double.TryParse(TTime1.Text.ToString(), out double ttime1) ? ttime1 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Test1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Send("CSGT1", (double.TryParse(TTime1.Text.ToString(), out double ttime1) ? ttime1 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime1_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    Send("GT1", (double.TryParse(TTime1.Text.ToString(), out double ttime1) ? ttime1 : 1).ToString());
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime2_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    Send("GT2", (double.TryParse(TTime2.Text.ToString(), out double ttime2) ? ttime2 : 1).ToString());
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime2_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {

                Send("GTS2", (double.TryParse(TTime2.Text.ToString(), out double ttime2) ? ttime2 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Test2_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Send("CSGT2", (double.TryParse(TTime2.Text.ToString(), out double ttime2) ? ttime2 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime3_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    Send("GT3", (double.TryParse(TTime3.Text.ToString(), out double ttime3) ? ttime3 : 1).ToString());
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime3_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {

                Send("GTS3", (double.TryParse(TTime3.Text.ToString(), out double ttime3) ? ttime3 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Test3_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Send("CSGT3", (double.TryParse(TTime3.Text.ToString(), out double ttime3) ? ttime3 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime4_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    Send("GT4", (double.TryParse(TTime4.Text.ToString(), out double ttime4) ? ttime4 : 1).ToString());
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime4_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {

                Send("GTS4", (double.TryParse(TTime4.Text.ToString(), out double ttime4) ? ttime4 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Test4_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Send("CSGT4", (double.TryParse(TTime4.Text.ToString(), out double ttime4) ? ttime4 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime5_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    Send("GTS5", (double.TryParse(TTime5.Text.ToString(), out double ttime5) ? ttime5 : 1).ToString());
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime5_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {

                Send("GTS5", (double.TryParse(TTime5.Text.ToString(), out double ttime5) ? ttime5 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Test5_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Send("CSGT5", (double.TryParse(TTime5.Text.ToString(), out double ttime5) ? ttime5 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime6_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    Send("GT6", (double.TryParse(TTime6.Text.ToString(), out double ttime6) ? ttime6 : 1).ToString());
                }
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TTime6_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {

                Send("GTS6", (double.TryParse(TTime6.Text.ToString(), out double ttime6) ? ttime6 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Test6_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Send("CSGT6", (double.TryParse(TTime6.Text.ToString(), out double ttime6) ? ttime6 : 1).ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void LGDJXJ1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("LGDJXJ1", LGDJXJ1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YGDJQJ1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YGDJQJ1", YGDJQJ1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YGDJHT1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YGDJHT1", YGDJHT1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void JG2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("JG2", JG2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YG2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YG2", YG2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void LGDJXJ2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("LGDJXJ2", LGDJXJ2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YGDJQJ2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YGDJQJ2", YGDJQJ2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YGDJHT2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YGDJHT2", YGDJHT2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void JG3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("JG3", JG3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YG3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YG3", YG3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void LGDJXJ3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("LGDJXJ3", LGDJXJ3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YGDJQJ3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YGDJQJ3", YGDJQJ3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void YGDJHT3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("YGDJHT3", YGDJHT3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TGS1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("TGS1", TGS1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TGX1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("TGX1", TGX1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TGS2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("TGS2", TGS2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TGX2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("TGX2", TGX2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GT1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("GT1", GT1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GT2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("GT2", GT2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GT3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("GT3", GT3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GT4_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("GT4", GT4_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GT5_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("GT5", GT5_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void GT6_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("GT6", GT6_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void SF1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("SF1", SF1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void SF2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("SF2", SF2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void SF3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("SF3", SF3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void SF4_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("SF4", SF4_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void SF5_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("SF5", SF5_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void QBQJ_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("QBQJ", QBQJ_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void QBHT_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("QBHT", QBHT_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }
        private void Y2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                caozuo1.Visibility = Visibility.Collapsed;
                caozuo2.Visibility = Visibility.Visible;
                caozuo3.Visibility = Visibility.Collapsed;
                Y1.Foreground = new SolidColorBrush(Color.FromRgb(39, 119, 123));
                Y2.Foreground = new SolidColorBrush(Color.FromRgb(32, 188, 195));
                Y3.Foreground = new SolidColorBrush(Color.FromRgb(39, 119, 123));
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Y1_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                caozuo1.Visibility = Visibility.Visible;
                caozuo2.Visibility = Visibility.Collapsed;
                caozuo3.Visibility = Visibility.Collapsed;
                Y2.Foreground = new SolidColorBrush(Color.FromRgb(39, 119, 123));
                Y1.Foreground = new SolidColorBrush(Color.FromRgb(32, 188, 195));
                Y3.Foreground = new SolidColorBrush(Color.FromRgb(39, 119, 123));
            }
            catch (Exception)
            {
                return;
            }
        }

        private void Y3_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                caozuo1.Visibility = Visibility.Collapsed;
                caozuo2.Visibility = Visibility.Collapsed;
                caozuo3.Visibility = Visibility.Visible;
                Y1.Foreground = new SolidColorBrush(Color.FromRgb(39, 119, 123));
                Y3.Foreground = new SolidColorBrush(Color.FromRgb(32, 188, 195));
                Y2.Foreground = new SolidColorBrush(Color.FromRgb(39, 119, 123));
            }
            catch (Exception)
            {
                return;
            }
        }

        private void WLY1_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                wuliao1.Visibility = Visibility.Visible;
                wuliao2.Visibility = Visibility.Collapsed;
                WLY2.Foreground = new SolidColorBrush(Color.FromRgb(39, 119, 123));
                WLY1.Foreground = new SolidColorBrush(Color.FromRgb(32, 188, 195));
            }
            catch (Exception)
            {
                return;
            }
        }

        private void WLY2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                wuliao2.Visibility = Visibility.Visible;
                wuliao1.Visibility = Visibility.Collapsed;
                WLY1.Foreground = new SolidColorBrush(Color.FromRgb(39, 119, 123));
                WLY2.Foreground = new SolidColorBrush(Color.FromRgb(32, 188, 195));
            }
            catch (Exception)
            {
                return;
            }
        }

        private void FYJ1_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("FYJ1", FYJ1_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void FYJ2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("FYJ2", FYJ2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TGS3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("TGS3", TGS3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }

        }

        private void TGX3_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("TGX3", TGX3_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void TGZ_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("TGZ", TGZ_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }

        }

        private void LB2_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("LB2", LB2_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }

        private void CB_IMG_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Send("CB", CB_IMG.Tag.ToString());
            }
            catch (Exception)
            {
                return;
            }
        }
    }
}
